def split_file(input_file, lines_per_file):
    with open(input_file, 'r') as f:
        current_line = 0
        file_number = 1
        output_file = open(f'output_{file_number}.txt', 'w')

        for line in f:
            if current_line == lines_per_file:
                output_file.close()
                file_number += 1
                output_file = open(f'output_{file_number}.txt', 'w')
                current_line = 0

            output_file.write(line)
            current_line += 1

        output_file.close()


split_file('large_file.txt', 1000000)  # 将大文件按每1000行拆分
